package com.tpp.service;

import com.tpp.entity.*;
import com.tpp.mapper.UserMapper;
import com.tpp.util.SpringUtil;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
//简单粗暴的解释就是：
// @Service告诉系统此类以及已经注册了，你可以用@Autowired来new出对象来。
// 系统帮你在用到的地方自动new了一个UserService的对象，名字叫userService
// 等同于UserService userService = new UserService();
// 配合@Autowired使用，@Autowired用来new，
public class UserService {
    @Autowired
    private UserMapper userMapper;//通过 Autowired注解实例化对象userMapper；
    public User checkLogin(String user_name, String user_pwd){
        User user = null;
        String where_condition = " where User_name="+user_name+" and User_pwd="+user_pwd;
        System.out.println(where_condition);
        user=userMapper.checkLogin(where_condition);

        return user;
    }
    public User checkUsername(String user_name){
        User user = null;
        String where_condition = " where User_name="+user_name;
        System.out.println(where_condition);
        user=userMapper.checkLogin(where_condition);

        return user;
    }

    public List<FilmItemShow> findOnlineFilms() {
        return userMapper.findOnlineFilms();
    }
    public List<CinemaInfo> findCinemaRank() {
        return userMapper.findCinemaRank();
    }
    public List<FilmItemShow> findAllOnlieFilms() {
        return userMapper.findAllOnlieFilms();
    }
    public List<CinemaInfo> findAllCinema() {
        return userMapper.findAllCinema();
    }
    public  String findCinemaNameBytimesId( int time_id){
        return userMapper.findCinemaNameBytimesId(time_id);
    }
    public FilmTime findTimeInfoByTimesId( int time_id){
        return userMapper.findTimeInfoByTimesId( time_id);
    }
    public Film findFilmIfoByTimesId(int time_id){
        return userMapper.findFilmIfoByTimesId(time_id);
    }
    public  String findPhonenumberByUesrId( int user_id){
        return userMapper.findPhonenumberByUesrId(user_id);
    }
    public int AddOrder(Order order){
        return userMapper.AddOrder(order);
    }
    public int AddOrderSeat(int hang,int lie,String orderId){
        return userMapper.AddOrderSeat(hang,lie,orderId);
    }
    public int  updateSeat(String seat,int time_id){
        return userMapper.updateSeat(seat,time_id);
    }
    public String findSeatInfoByTimesId1( int time_id){
        return userMapper.findSeatInfoByTimesId1(time_id);
    }
    public int AddUser(String userCode,String  userPwd,String phone){
        return userMapper.AddUser(userCode,userPwd,phone);
    }



    public List<User> getAllUser_wx(){
        return userMapper.getAllUser_wx();
    }
    public int findUserIdByUsername(String username){
        return userMapper.findUserIdByUsername(username);
    }
}
